<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
	isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<html>
<head>
<base href="<%=basePath%>">
<!-- http://localhost:8080/gzsxtpm/ -->
<title>My JSP 'tenant_contact.jsp' starting page</title>

<link rel="shortcut icon" href="favicon.ico">
<link href="css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
<link href="css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
<link href="css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="css/animate.min.css" rel="stylesheet">
<link href="css/style.min862f.css?v=4.1.0" rel="stylesheet">
<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>



<script src="js/plugins/jeditable/jquery.jeditable.js"></script>

<!-- Data Tables -->
<script src="js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="js/plugins/dataTables/dataTables.bootstrap.js"></script>
<!-- layer javascript  引用layer插件 -->
<script src="js/plugins/layer/layer.min.js"></script>

<script src="js/content.min.js?v=1.0.0"></script>
<script src="js/plugins/iCheck/icheck.min.js"></script>
<script src="js/plugins/layer/layer.js"></script>
<script src="js/plugins/layer/laydate/laydate.js"></script>

<!-- 引入 Jquery.validate.js 表单验证框架 -->
<script src="js/jquery.validate.min.js"></script>
<script src="js/messages_zh.min.js"></script>


<!-- 自定义js -->
<script src="js/content.js?v=1.0.0"></script>
<style type="text/css">
</style>
</head>

<body class="gray-bg">

	<div class="wrapper wrapper-content animated fadeInRight">

		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">

					<div class="ibox-content">
						<form id="constractForm" method="post"
							action="contractServlet.gzsxt?cmd=addcontract"
							class="form-horizontal" name="constractaddform">
							房间对应的ID : ${param.roomId}

							<!-- 隐藏域,用于提交房间对应的id -->
							<input type="hidden" name="room_id" value="${param.roomId}">
							<div class="form-group">

								<label class="col-sm-2 control-label">选择租户：</label>
								<div class="col-sm-10">
									<select class="form-control" name="tenant_id">
										<option value="1">张一-身份证号</option>
										<option value="2">张二-身份证号</option>
										<option value="3">张三-身份证号</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">物业费类型：</label>
								<div class="col-sm-10">
									<select class="form-control" name="pcharge_id">
										<option value="1">办公A类</option>
										<option value="2">商铺B类</option>
										<option value="3">仓库C类</option>
										<option value="4">其它</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">用途：</label>
								<div class="col-sm-10">
									<select class="form-control" name="purpose_id">
										<option value="1">商铺</option>
										<option value="2">办公</option>
										<option value="3">仓库</option>
										<option value="4">其它</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">签约日期：</label>
								<div class="col-sm-10">
									<input id="signtime" name="signtime"
										class="form-control layer-date" placeholder="YYYY-MM-DD"
										onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
									<label class="laydate-icon"></label>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">起租日期：</label>
								<div class="col-sm-4">
									<input name="starttime" placeholder="开始日期"
										class="form-control layer-date laydate-icon" id="start">
								</div>
								<label class="col-sm-2 control-label">停租日期：</label>
								<div class="col-sm-4">
									<input name="endtime" placeholder="结束日期"
										class="form-control layer-date laydate-icon" id="end">
								</div>
							</div>



							<div class="form-group">
								<label class="col-sm-2 control-label">月租金：</label>
								<div class="col-sm-10">
									<input name="monthfee" placeholder="月租金" class="form-control"
										name="pwd">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">押金：</label>
								<div class="col-sm-10">
									<input type="text" name="deposit" placeholder="押金"
										class="form-control">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">备注说明：</label>
								<div class="col-sm-10">
									<textarea name="remarks" class="form-control" rows="3"></textarea>
								</div>
							</div>

							<div class="form-group">
								<div class="col-sm-4 col-sm-offset-2">
									<button id="subid" class="btn btn-primary" type="submit">保存内容</button>
									<button class="btn btn-white" type="reset">取消</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>



	<script type="text/javascript">
		var start = {
			elem : '#start',
			format : 'YYYY-MM-DD',
			min : laydate.now(), //设定最小日期为当前日期
			max : '2099-06-16 23:59:59', //最大日期
			istime : true,
			istoday : false,
			choose : function(datas) {
				end.min = datas; //开始日选好后，重置结束日的最小日期
				end.start = datas //将结束日的初始值设定为开始日
			}
		};
		var end = {
			elem : '#end',
			format : 'YYYY-MM-DD ',
			min : laydate.now(),
			max : '2099-06-16 23:59:59',
			istime : true,
			istoday : false,
			choose : function(datas) {
				start.max = datas; //结束日选好后，重置开始日的最大日期
			}
		};
		laydate(start);
		laydate(end);
	</script>
	<script type="text/javascript">
		$(function() {
			//校验表单
			$("#constractForm").validate({
				rules : {
					signtime : "required",
					starttime : "required",
					endtime : "required",
					monthfee : "required",
					deposit : "required",
					remarks : "required"
				},
				messages : {
					signtime : "签约日期不能为空",
					starttime : "起租日期不能为空",
					endtime : "结束日期不能为空",
					monthfee : "租金不能为空",
					deposit : "押金不能为空",
					remarks : "备注不能为空"
				},/* 校验完毕触发的事件 */
				submitHandler : function() {
					//序列化表单数据
					var fromData = $("#constractForm").serialize();
					
					console.log(fromData);
					//使用ajax 向后台提交数据
					$.post("${ctx}/constract.gzsxt?cmd=addConstract",fromData,function(data){
						if(data.code == 1){
							parent.layer.open({
								type : 1,
								skin : 'layui-layer-molv', //样式类名
								closeBtn : false, //不显示关闭按钮
								shift : 4,//动画效果
								shadeClose : true, //开启遮罩关闭
								content : '合同签约成功',
								time:1000,////3秒关闭（如果不配置，默认是3秒）
								end:function(){
									
									//添加成功以后,再回调父 页面 manage_contract.jsp的函数
									parent.changeRoomStatus("${param.tId}");
									
									//获取父窗口的弹出层 的层级
									var index = parent.layer.getFrameIndex(window.name);
									parent.layer.close(index);
								}
						});
						}
					});
				}
			});

		})
	</script>


</body>
</html>

